|
|
|
| |
|
|
|
|
Notice that the Edit menu is no longer visible, even in the design environment. You can still access the menu item's Click event procedure by entering the form's Code window and selecting the appropriate menu item from the object box. If you prefer, you can also leave the menu item's Visible property set to True and use the form's Load event procedure to set it to False. |
|
|
|
|
|
|
|
|
|
|
Follow these steps to enable the appropriate portions of the File menu and to make the Edit menu visible whenever a document is opened: |
|
|
|
|
|
|
|
|
1. In the design environment, click the File menu, and then click the Open menu item. You are presented with mnuFileOpen's Click event procedure. |
|
|
|
|
|
|
|
|
2. In a fully functional application, your code for opening a file would be placed here. You can use a comment line to represent that portion of the code. Enter these lines of code into the mnuFileOpen_Click procedure: |
|
|
|
|
|
|
|
|
'Code for opening a file goes here
mnuFileSave.Enabled = True
mnuFileSendTo.Enabled = True
mnuFilePrint.Enabled = True
mnuEdit.Visible = True |
|
|
|
|
|
|
|
|
3. Close the Menu Editor. |
|
|
|
|
|
|
|
|
4. Save and run your application. Notice that the Edit menu can't be seen. Notice also that when you click the File menu, some of the items are grayed out. |
|
|
|
|
|
|
|
|
5. Choose File, Open, which causes the Open menu item's Click event procedure to be executed. Choose the File menu again, and notice that all File menu items are now available. Notice also that the Edit menu is now visible. |
|
|
|
|
|
|
|
|
6. Click the End button on the toolbar to end the program. |
|
|
|
|
|
|
|
|
The Checked property of the menu item determines whether a check mark is displayed to the left of the item in the menu, as shown in Figure 6.9. The Checked property is typically used to indicate the status of a program option; for example, if a user has selected a particular option, a check mark appears next to that item in the menu. The menu item is then used to toggle back and forth between two program states. |
|
|
|
|
|
|
|
|
Figure 6.9
The Checked property determines whether a
check marks is placed to the left of a submenu item. |
|
|
|
|
|
|
|
|
Enter the following code into the Click event procedure of the mnuOptionsText menu item in the sample menu: |
|
|
|
|
|
|
|
|
mnuOptionsText.Checked = Not mnuOptionsText.Checked |
|
|
|
|
|